<script setup lang="ts">
// 函数 参数类型 返回值类型
/*function test(x: number, y: number): number {
  return x + y;
}

let a = test(2, 2);
console.log(a);*/

/*let test = function (x: number, y: number): number {
  return x * y;
};
let a = test(2, 2);
console.log(a);*/

/*let test = (x: number, y: number): number => {
  return x / y;
};
let a = test(3, 2);
console.log(a);*/

// 可选参数
/*let test = (x: number, y: number, z: number, n?: number): number => x + y + z + n;
let a = test(2, 3, 4,200);
let b = test(2, 3, 4);
console.log(a);
console.log(b);*/

// 默认参数
/*let test = (x: number, y: number = 20): number => x + y;
let a = test(2);
let b = test(2, 30.99);
console.log(a);
console.log(b);*/

//null代表一个确定的值，undefined代表一个不确定的值
// 任意类型都也可以undefined赋值
/*let test = (): null => null;
let test1 = (): undefined => {
  return undefined;
};
console.log(test());
console.log(test1());*/

/*let test1 = (): undefined => undefined;
let test2 = () => undefined;
let test3 = (): undefined => {
  return;
};
console.log(test1());
console.log(test2());
console.log(test3());*/

//该函数可以没有return 或直接 return 不加/undefined/null
/*let test1 = (): void => {
  console.log("test");
};
let test2 = (): void => {
  return;
};
let test3 = (): void => {
  return undefined;
};
test1();
console.log(test2());
console.log(test3());*/

/*let test1 = (): never => {
  throw new Error("test");
};
console.log(test1())*/
/*let test2 = (): never => {
  while (true) {
    console.log("test")
  }
};
test2();*/


</script>

<template>

</template>

<style scoped>

</style>